package com.csw.shuanfa.CodeImprove.redlockThread.locktest;

import com.csw.shuanfa.CodeImprove.redlockThread.locktest.service.RedLockService;
import com.csw.shuanfa.CodeImprove.redlockThread.locktest.service.SingleService;
import com.csw.shuanfa.CodeImprove.redlockThread.locktest.service.SynchronizedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("RedLock")
public class RedLockTestController {
    @Autowired
    private SingleService singleService;
    @Autowired
    private SynchronizedService synchronizedService;

    @Autowired
    private RedLockService redLockService;

    /**
     * 单体
     */
    @RequestMapping("ServerDan")
    public void ServerDan() {
        singleService.oversold(100);
    }


    /**
     * //模拟原子锁,单体服务，成功
     * Synchronized
     */
    @RequestMapping("ServerSynchronized1")
    public void ServerSynchronized1() {
        synchronizedService.oversold(100);
    }


    /**
     * //模拟原子锁,单体服务，成功
     * 分布式锁
     */
    @RequestMapping("ServiceRedlock")
    public void ServiceRedlock() {
        redLockService.oversold(100);
    }


}
